<template>
  <van-row class="main-menu">
    <van-nav-bar left-text="返回" title="单位评分跟踪" @click-left="doBack"/>
    <van-cell-group>
        <van-cell title="当前阶段" :value="stage" />
    </van-cell-group>
    <van-empty v-if="showEmpty" description="无分析数据" />
    <van-row>

      <dept-grade-stage-monitor v-if='stage === "评分阶段"' :chartData='chartData' :tableData='tableData' />
      <dept-feedback-stage-monitor v-if='stage === "确认及反馈阶段"' :chartData='chartData' :tableData='tableData' />
      <dept-review-stage-monitor v-if='stage === "终审阶段"' :chartData='chartData' :tableData='tableData' />
       <!--
      <dept-feedback-stage-monitor v-if='stage === "确认及反馈阶段"' :chartData='chartData' :tableData='tableData' />-->
    </van-row>
    <van-cell-group>
        <van-cell title="当前加分阶段" :value="addStage" />
    </van-cell-group>
  </van-row>
</template>

<script>
import DeptFeedbackStageMonitor from '@/views/analysis/DeptFeedbackStageMonitor'
import DeptGradeStageMonitor from '@/views/analysis/DeptGradeStageMonitor'

import DeptReviewStageMonitor from '@/views/analysis/DeptReviewStageMonitor'

import { getDeptGradeMonitor } from '@/api/analysis'

export default {
  name: 'DeptGradeMonitor',
  components: { DeptGradeStageMonitor, DeptFeedbackStageMonitor, DeptReviewStageMonitor },
  // components: { DeptFeedbackStageMonitor },
  data () {
    return {
      stage: '无阶段',
      addStage: '无加分批次',
      echarts: null,
      options: null,
      showEmpty: false,
      colorArray: ['#a90000', '#f4e001', '#2b821d', '#2b821d'],
      condition: {
        department_path: ''
      },
      dataDetail: null,
      chartData: null,
      tableData: null
    }
  },
  mounted () {
    this.condition.department_path = this.$store.state.authInfo.currentDept.department_path
    console.log(this.$store.state.authInfo.currentDept)

    this.doGetDeptGradeMonitor()
  },
  methods: {
    doBack () {
      // this.$store.commit('authInfo/delRectifyDept')
      this.$router.back()
    },
    doGetDeptGradeMonitor () {
      getDeptGradeMonitor(this.condition).then(res => {
        let { data } = res
        if (data[this.$response.CODE] === this.$response.SUCCESS) {
          let retdata = data[this.$response.DATA] ? data[this.$response.DATA] : null
          this.stage = retdata.stage
          this.addStage = retdata.addStage

          this.chartData = retdata.gradeTotal[0]
          this.tableData = retdata.gradeDetail
          this.showEmpty = retdata === null
        } else {
          this.$toast.fail('获取数据失败：' + data[this.$response.MESSAGE])
        }
      }, errFunc => {
        this.$notify('服务调用失败：' + errFunc.toString())
        console.log(errFunc.toString())
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
